{% extends "base-user.html" %}

{% block css%}    
{% endblock %}
{% block js%} 
<script>
function kill(pid_){
    if(confirm('确定?')) {
        $.getJSON("{% url 'PiApp.api.kill_process_api' %}",  {pid : pid_}, 
            function(data){
                if(data['msg'] != 'ok') {
                    alert('失败');
                }               
        });
    }  
}
</script>   
{% endblock %}


{% block on_ready%}    
{% endblock %}

{% block content %} 

<div class="row ">
  <div class="col-md-12">
    <div class="box box-solid box-navy ">
      <div class="box-header">
        <i class="fa fa-laptop"></i>
        <h3 class="box-title">进程</h3>
      </div><!-- /.box-header -->
      <div class="box-body  ">
        <table class="table table-hover">
          <tbody><tr>
            <th style="width:8%;">PID</th>
            <th style="width:15%;">所有者</th>
            <th style="width:41%;">命令行</th>
            <th style="width:10%;">CPU 占用率 (%)</th>
            <th style="width:10%;">Memory 占用率 (%)</th>
            <th style="width:16%;">终止</th>
          </tr>
          {% for item in process_info %}
          <tr>
            <td>{{item.pid}}</td>
            <td>{{item.owner}}</td>
            <td>{{item.command}}</td>
            <td>{{item.cpu}}</td>
            <td>{{item.memory}}</td>
            <td><button type="button" class="btn btn-danger" onclick="kill({{item.pid}})">kill</button></td>
          </tr>
          {% endfor %}

        </tbody></table>


      </div><!-- /.box-body -->

    </div><!-- /.box -->
  </div>
</div>
{% endblock %}